<?php 
require_once 'sesi_login.php';
require_once 'konfigurasi.php';

fungsi('pegawai');

define('PAGE', 'Pegawai');
define('PAGE_ICO', 'icon-parents');
define('PAGE_URL', 'pegawai.php');

if(isset($_GET['tambah'])) {
	define('SUBPAGE', 'Tambah Pegawai');
	define('SUBPAGE_ICO', 'icon-circle-plus');
	define('SUBPAGE_URL', '?tambah');
} elseif(isset($_GET['detail'])) {
	define('SUBPAGE', 'Detail Pegawai');
	define('SUBPAGE_ICO', 'icon-user');
	define('SUBPAGE_URL', '?detail');
} elseif(isset($_GET['kinerja'])) {
	define('SUBPAGE', 'Kinerja Pegawai');
	define('SUBPAGE_ICO', 'icon-charts');
	define('SUBPAGE_URL', '?kinerja');
} elseif(isset($_GET['tambahjabatan'])) {
	define('SUBPAGE', 'Pegawai Jabatan');
	define('SUBPAGE_ICO', 'icon-charts');
	define('SUBPAGE_URL', '?tambahjabatan');
} elseif(isset($_GET['tambahpangkat'])) {
	define('SUBPAGE', 'Pegawai Pangkat');
	define('SUBPAGE_ICO', 'icon-charts');
	define('SUBPAGE_URL', '?tambahpangkat');
}

koneksi_buka();
panggil_header();
?>

<div id="da-content-area">
<div class="row-fluid">

<div class="span12">
	<?php
		if(isset($_GET['tambah'])) {
			require 'modul/pegawai/pegawai.tambah.php';
		} elseif(isset($_GET['kinerja'])) {
			require 'modul/pegawai/pegawai.kinerja.php';
		} elseif(isset($_GET['detail'])) {
			if(isset($_GET['aktifitas'])) {
				require 'modul/pegawai/pegawai.aktifitas.php';
			} elseif(isset($_GET['statistik'])) {
				require 'modul/pegawai/pegawai.statistik.php';
			} elseif(isset($_GET['akses'])) {
				require 'modul/pegawai/pegawai.jaksa.php';
			} elseif(isset($_GET['kinerja'])) {
				require 'modul/pegawai/pegawai.kinerja.php';
			} else {
				require 'modul/pegawai/pegawai.detail.php';
			}
		} elseif(isset($_GET['tambahpangkat'])) {
			require 'modul/pegawai/pegawai.pangkat.php';
		} elseif(isset($_GET['tambahjabatan'])) {
			require 'modul/pegawai/pegawai.jabatan.php';
		} else {
	?>
	<div class="da-panel">
		<div class="da-panel-header">
			<span class="da-panel-title">
				<i class="icon-parents"></i> Data Pegawai &nbsp;
				<a href="?tambah" rel="tooltip" data-placement="top" class="btn" title="Tambah Pegawai"><i class="icon-circle-plus"></i></a>
				<a href="?kinerja" rel="tooltip" data-placement="top" class="btn" title="Kinerja Jaksa"><i class="icon-charts"></i></a>
			</span>
		</div>
		<div class="da-panel-content da-table-container">
		<?php
			if(isset($_GET['suksestambah'])) { ?>
				<div class="da-message success">
					Data pegawai berhasil ditambahkan
				</div>
		<?php } elseif(isset($_GET['suksesubah'])) { ?>
				<div class="da-message success">
					Data pegawai berhasil diperbarui
				</div>
		<?php } elseif(isset($_GET['sukseshapus'])) { ?>
				<div class="da-message warning">
					Data pegawai telah dihapus
				</div>
		<?php } ?>
<table id="da-ex-datatable-numberpaging" class="da-table checkable">
	<thead>
		<tr>
			<th>NIP</th>
			<th>NAMA LENGKAP</th>
			<th>JABATAN</th>
			<th></th>
		</tr>
	</thead>
	<tbody>
		<?php 
			$q = mysql_query("
				SELECT kd_pegawai,nip,nm_lengkap,nm_jabatan, a.kd_jabatan
				FROM t_pegawai a
				LEFT JOIN r_jabatan b
				ON a.kd_jabatan=b.kd_jabatan
				ORDER BY a.kd_pegawai
			");
			while($dt = mysql_fetch_array($q)) {
		?>
		<tr>
			<td><?php echo nip($dt['nip']) ?></td>
			<td><?php echo $dt['nm_lengkap'] ?></td>
			<td><?php echo $dt['nm_jabatan'] ?></td>
			<td>
				<a href="modul/pegawai/pegawai.proses.php?kd=<?php echo $dt['kd_pegawai'] ?>" 
				rel="tooltip" data-placement="top" title="Hapus"
				id="pegawai-hapus"
				>
					<i class="icol-cross"></i>
				</a>&nbsp;&nbsp;&nbsp;
				<a href="?detail=<?php echo $dt['kd_pegawai'] ?>" rel="tooltip" data-placement="top" title="Detail"><i class="icol-magnifier"></i></a>
			</td>
		</tr>
		<?php } ?>
	</tbody>
</table>		
		
		</div>
	</div>
	<?php } ?>
</div>

</div>
</div>

<?php
panggil_footer();
koneksi_tutup();
?>
